package middleware

import (
	"editor/constant"
	"fmt"
	"github.com/gin-gonic/gin"
	"time"
)

func BaseParams() gin.HandlerFunc {
	return func(c *gin.Context) {

		// 当前用户名
		c.Set(constant.UserName, "")
		// 当前访问的时间（微秒）
		c.Set(constant.RequestTime, time.Now().UnixMicro())
		//写日志ID
		logId := time.Now().UnixMicro()
		c.Set(constant.LogId, logId)
		c.Writer.Header().Set("LogId", fmt.Sprintf("%d", logId))

		c.Next()
	}
}
